package testJdk.commonUse.collections.map;


import org.junit.Test;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;

import java.util.List;
import java.util.Map;

/**
 * @version 1.0.0
 * Created by cyd on 2023-04-20 18:47:31
 * @Description : 测试一个键对应多个值的map
 */
public class MultiValueMapTest {

    /**
     * 测试一个键对应多个值的map
     */
    @Test
    public void test01() {
        MultiValueMap<String, String> multiMap = new LinkedMultiValueMap<>();
        multiMap.add("1", "1");
        multiMap.add("1", "2");
        multiMap.add("1", "3");
        multiMap.add("1", "4");
        multiMap.add("1", "5");
        multiMap.add("2", "1");
        multiMap.add("2", "2");
        multiMap.add("3", "1");
        for (Map.Entry<String, List<String>> stringListEntry : multiMap.entrySet()) {
            System.out.println("key:" + stringListEntry.getKey());
            List<String> value = stringListEntry.getValue();
            System.out.println("value:" + value);
        }
    }


}
